#include <cstdio>
#include <stack>
#include <vector>

const int N = 100005;
int n, m, k, u[N << 1], v[N << 1], fa[N], dep[N], siz[N];
std::vector<int> e[N << 2], a[N << 1];

struct Node {
  int x, siz;
  bool chek;
  Node(int x, int siz, bool chek) : x(x), siz(siz), chek(chek) {}
};

std::stack<Node> stk;

int find(int x) { return fa[x] == x ? x : find(fa[x]); }

inline void merge(int &x, int &y) {
  x = find(x), y = find(y);
  if (dep[x] > dep[y]) std::swap(x, y);
  fa[x] = y, dep[y] += dep[x] == dep[y], siz[y] += siz[x];
  stk.push(Node(x, siz[x], dep[x] == dep[y]));
}

void insert(int x, int l, int r, int L, int R, int id) {
  if (L <= l && r <= R) {
    e[x].push_back(id);
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) insert(x << 1, l, mid, L, R, id);
  if (mid < R) insert(x << 1 | 1, mid + 1, r, L, R, id);
}

void solve(int x, int l, int r) {
  bool flag = false;
  size_t size = stk.size();
  for (auto &iter : e[x]) {
    int from = find(u[iter]), to = find(v[iter]);
    if (from == to) continue;
    //    if (dep[from] < dep[to]) std::swap(from, to);
    //    fa[to] = from, dep[from] += dep[to] == dep[from], siz[from] += siz[to];
    //    stk.push(Node(to, dep[to] == dep[from], siz[to]));
    merge(from, to);
    if (siz[to] == n) {
      for (int i = l; i <= r; ++i) puts("Connected");
      flag = true;
      break;
    }
  }
  int mid = (l + r) >> 1;
  //  if (l == r) puts(flag ? "con" : "dis");
  //  else solve(x << 1, l, mid, flag), solve(x << 1 | 1, mid + 1, r, flag);
  if (!flag) {
    if (l == r)
      puts("Disconnected");
    else
      solve(x << 1, l, mid), solve(x << 1 | 1, mid + 1, r);
  }
  while (stk.size() > size) {
    siz[fa[stk.top().x]] -= stk.top().siz;
    dep[fa[stk.top().x]] -= stk.top().chek;
    fa[stk.top().x] = stk.top().x, stk.pop();
  }
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("P5227 [AHOI2013]连通图.in", "r", stdin);
  freopen("P5227 [AHOI2013]连通图.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &u[i], &v[i]);
    a[i].push_back(0);
  }
  scanf("%d", &k);
  for (int i = 1, c, id; i <= k; ++i) {
    scanf("%d", &c);
    for (int j = 1; j <= c; ++j) scanf("%d", &id), a[id].push_back(i);
  }
  for (int i = 1; i <= m; ++i) a[i].push_back(k + 1);

  for (int i = 1; i <= m; ++i) {
    for (auto iter = a[i].begin() + 1; iter != a[i].end(); ++iter) {
      if (*(iter - 1) + 1 <= *iter - 1)
        insert(1, 1, k, (*(iter - 1)) + 1, (*iter) - 1, i);
    }
  }
  for (int i = 1; i <= n; ++i) fa[i] = i, siz[i] = 1;
  solve(1, 1, k);
  return 0;
}